package com.sunjob.common.exceptionHandler;

import com.sunjob.common.exception.MROException;
import com.sunjob.common.result.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by IntelliJ IDEA.
 *
 * @Author : Wangzurong
 * @create 2022-07-23 16:13
 * 全局异常处理器
 */
@ControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result error(Exception e){
        e.printStackTrace();
        return Result.fail(e.getMessage());
    }
    @ExceptionHandler(MROException.class)
    @ResponseBody
    public Result mroError(MROException e){
        e.printStackTrace();
        return Result.fail(e.getMessage());
    }
}
